var $tm = $('#t_m');
var $ts = $('#t_s');
var t = setInterval(function(){
	//console.log("time[" + $tm.html() + "][" + $ts.html());
	var m = $tm.html();
	var s = $ts.html();
	if(m==0 && s==0){
		//clearInterval(t);
		over();
	}
	if(s==0){
		m--;
		s = 59;
	}else{
		s--;
	}		
	$tm.html(m);
	$ts.html(s);
},1000);

/**
 * 公务员考试的题型有以下几种：
	言语理解与表达部分总共40个题目，每个题目0.6分，共计24分
	数量关系部分总共20个题目，每题1分，共计20分
	判断推理总共35个题目，图形推理每题0.5分，定义判断每题0.8分，类比推理每题0.5分，演绎推理每题0.8分，共计23.5分
	常识部分总共25题，每题0.5分，共计12.5分
	资料部分，共20题，每题1分，共计20分
 * */
var score = 100;
var over = function(){
	var $yyljybd = $('#yyljybd');
	var $slgx = $('#slgx');
	var $pdtl = $('#pdtl');
	var $cspd = $('#cspd');
	var $zlfx = $('#zlfxt');
	var yyljybd_score = check($yyljybd,0.6);
	var slgx_score = check($slgx,1);
	var pdtl_score = check($pdtl,0.67);
	var cspd_score = check($cspd,0.5);
	var zlfx_score = check($zlfx,1);
	
	var $progress_score = $("#progress_score");
	$progress_score.css("width",score + "%");
	$progress_score.html(score + "分");
	
	
	clearInterval(t);
	$progress_score.parent().show();
	$('.analysis').show();
}
var check = function(category,_score){
	var $uls = category.find('ul');
	var returnScore = 0;
	for(var i = 0 ; i < $uls.length ; i++){
		var $ul = $uls.eq(i);
		var $input = $ul.find('input[type=radio]:checked');
		if($input != undefined){
			var user_answer = $input.val();
			var answer = $ul.find('.wp_analysis').html();
			console.log($input);
			console.log($ul + "][" + $input + "][" + user_answer + "][" + answer);
			if(answer != user_answer){
				returnScore += _score;
				$ul.addClass('wp_err');
			}
		}else{
			returnScore += _score;
			$ul.addClass('wp_err');
		}
	}
	score -= returnScore;
	return returnScore;
}
			